﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Caching;
namespace ECommerce.DAO.Cache.Personas
{
    public static class Persona
    {
        public static ECommerce.Model.Personas.Persona GetPersonaById(Int32 Id)
        {
            return (ECommerce.Model.Personas.Persona)ECommerce.DAO.Cache.CacheHelper.GetObjetoById(Id);
            //ECommerce.Model.Personas.Persona Persona = new ECommerce.Model.Personas.Persona();
            //try
            //{
            //    Persona = (ECommerce.Model.Personas.Persona)HttpRuntime.Cache["Persona-" + Id.ToString()];
            //}
            //catch (Exception ex)
            //{
            //    Persona = null;
            //}
            //if (Persona != null && Persona.Id == 0)
            //    Persona = null;
            //return Persona;
        }
        public static int SetPersona(ECommerce.Model.Personas.Persona Persona)
        {
            return ECommerce.DAO.Cache.CacheHelper.SetObjeto(Persona);
            //try
            //{
            //    HttpRuntime.Cache.Insert("Persona-" + Persona.Id.ToString(), Persona);
            //}
            //catch (Exception ex)
            //{
            //}
            //return Persona.Id;
        }
        public static int DelPersona(ECommerce.Model.Personas.Persona Persona)
        {
            return ECommerce.DAO.Cache.CacheHelper.DelObjeto(Persona);
            //try
            //{
            //    HttpRuntime.Cache.Remove("Persona-" + Persona.Id.ToString());
            //}
            //catch (Exception ex)
            //{
            //}
            //return Persona.Id;
        }

     }
}
